/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import edu.ucsur.tp.sistemainventario.beans.Proveedor;
import edu.ucsur.tp.sistemainventario.dao.ProveedorDAO;
import edu.ucsur.tp.sistemainventario.dao.factories.DAOFactory;

/**
 *
 * @author luis.hidalgo
 */
public class frmCreacionProveedor extends javax.swing.JFrame {

     DAOFactory factory = DAOFactory.getInstance(DAOFactory.MY_SQL);
    /**
     * Creates new form frmCreacionProveedor
     */
    public frmCreacionProveedor() {
        initComponents();
        this.setLocationRelativeTo(null);
        
        this.jcmDistrito.addItem("ATE");
        this.jcmDistrito.addItem("BARRANCO");
        this.jcmDistrito.addItem("BREÑA");
        this.jcmDistrito.addItem("CERCADO DE LIMA");
        this.jcmDistrito.addItem("CHORRILLOS");
        this.jcmDistrito.addItem("COMAS");
        this.jcmDistrito.addItem("EL AGUSTINO");
        this.jcmDistrito.addItem("INDEPENDENCIA");
        this.jcmDistrito.addItem("JESÚS MARÍA");
        this.jcmDistrito.addItem("LA MOLINA");
        this.jcmDistrito.addItem("LA VICTORIA");
        this.jcmDistrito.addItem("LINCE");
        this.jcmDistrito.addItem("LOS OLIVOS");
        this.jcmDistrito.addItem("MAGDALENA DEL MAR");
        this.jcmDistrito.addItem("MIRAFLORES");
        this.jcmDistrito.addItem("PUEBLO LIBRE");
        this.jcmDistrito.addItem("PUENTE PIEDRA");
        this.jcmDistrito.addItem("RIMAC");
        this.jcmDistrito.addItem("SAN BORJA");
        this.jcmDistrito.addItem("SAN ISIDRO");
        this.jcmDistrito.addItem("SAN JUAN DE LURIGANCHO");
        this.jcmDistrito.addItem("SAN JUAN DE MIRAFLORES");
        this.jcmDistrito.addItem("SAN LUIS");
        this.jcmDistrito.addItem("SAN MARTIN DE PORRES");
        this.jcmDistrito.addItem("SAN MIGUEL");
        this.jcmDistrito.addItem("SANTA ANITA ");
        this.jcmDistrito.addItem("SANTA ROSA");
        this.jcmDistrito.addItem("SANTIAGO DE SURCO");
        this.jcmDistrito.addItem("SURQUILLO");
        this.jcmDistrito.addItem("VILLA EL SAVADOR");
        this.jcmDistrito.addItem("VILLA MARÍA DEL TRIUNFO");
               
        
        this.jcmbProvincia.addItem("BARRANCA");
        this.jcmbProvincia.addItem("CANTA");
        this.jcmbProvincia.addItem("CHACLACAYO");
        this.jcmbProvincia.addItem("CHANCAY");
        this.jcmbProvincia.addItem("CHICLA");
        this.jcmbProvincia.addItem("CHOSICA");
        this.jcmbProvincia.addItem("HUACHO");
        this.jcmbProvincia.addItem("HUALMAY");
        this.jcmbProvincia.addItem("HUARAL");
        this.jcmbProvincia.addItem("HUAURA");
        this.jcmbProvincia.addItem("IMPERIAL");
        this.jcmbProvincia.addItem("LIMA");
        this.jcmbProvincia.addItem("LUNAHUANÁ");
        this.jcmbProvincia.addItem("MAGDALENA");
        this.jcmbProvincia.addItem("MALA");
        this.jcmbProvincia.addItem("MARCAHUASI");
        this.jcmbProvincia.addItem("MATUCANA");
        this.jcmbProvincia.addItem("MIRAFLORES");
        this.jcmbProvincia.addItem("NUEVO IMPERIAL");
        this.jcmbProvincia.addItem("OYÓN");
        this.jcmbProvincia.addItem("PARAMONGA");
        this.jcmbProvincia.addItem("PATIVILCA");
        this.jcmbProvincia.addItem("PUNTA HERMOSA");
        this.jcmbProvincia.addItem("QUILMANÁ");
        this.jcmbProvincia.addItem("RICARDO PALMA");
        this.jcmbProvincia.addItem("SAN LUIS");
        this.jcmbProvincia.addItem("SAN VICENTE DE CAÑETE");
        this.jcmbProvincia.addItem("SANTA EULALIA");
     
        this.jcmbDepartamento.addItem("AMAZONAS"); 
        this.jcmbDepartamento.addItem("ANCASH");
        this.jcmbDepartamento.addItem("APURIMAC"); 
        this.jcmbDepartamento.addItem("AREQUIPA"); 
        this.jcmbDepartamento.addItem("AYACUCHO"); 
        this.jcmbDepartamento.addItem("CAJAMARCA"); 
        this.jcmbDepartamento.addItem("CUSCO");
        this.jcmbDepartamento.addItem("CALLAO");
        this.jcmbDepartamento.addItem("HUANCAVELICA"); 
        this.jcmbDepartamento.addItem("HUANUCO");
        this.jcmbDepartamento.addItem("ICA"); 
        this.jcmbDepartamento.addItem("JUNIN"); 
        this.jcmbDepartamento.addItem("LA LIBERTAD"); 
        this.jcmbDepartamento.addItem("LAMBAYEQUE"); 
        this.jcmbDepartamento.addItem("LIMA"); 
        this.jcmbDepartamento.addItem("LORETO"); 
        this.jcmbDepartamento.addItem("MADRE DE DIOS"); 
        this.jcmbDepartamento.addItem("MOQUEGUA"); 
        this.jcmbDepartamento.addItem("PASCO"); 
        this.jcmbDepartamento.addItem("PIURA"); 
        this.jcmbDepartamento.addItem("PUNO"); 
        this.jcmbDepartamento.addItem("SAN MARTIN"); 
        this.jcmbDepartamento.addItem("TACNA"); 
        this.jcmbDepartamento.addItem("TUMBES"); 
        this.jcmbDepartamento.addItem("UCAYALI");
        
       
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jcmbDepartamento = new javax.swing.JComboBox();
        jcmbProvincia = new javax.swing.JComboBox();
        jcmDistrito = new javax.swing.JComboBox();
        jtxtTelefono = new javax.swing.JTextField();
        jtxtDireccion = new javax.swing.JTextField();
        jtxtRuc = new javax.swing.JTextField();
        jtxtRazon = new javax.swing.JTextField();
        jbtbAceptar = new javax.swing.JButton();
        jbntCancelar = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jtxtContacto = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtxtCorreo = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxaComentarios = new javax.swing.JTextArea();
        jtxtCodigo = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Codigo de Proveedor:");

        jLabel2.setText("Razon Social:");

        jLabel3.setText("Direccion:");

        jLabel4.setText("Departamento:");

        jLabel5.setText("Telefono:");

        jLabel6.setText("RUC:");

        jLabel7.setText("Provincia:");

        jLabel8.setText("Distrito:");

        jbtbAceptar.setText("ACEPTAR");
        jbtbAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtbAceptarActionPerformed(evt);
            }
        });

        jbntCancelar.setText("CANCELAR");
        jbntCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbntCancelarActionPerformed(evt);
            }
        });

        jLabel9.setText("Contacto:");

        jLabel10.setText("Correo Electronico:");

        jLabel11.setText("Comentarios:");

        jtxaComentarios.setColumns(20);
        jtxaComentarios.setRows(5);
        jScrollPane1.setViewportView(jtxaComentarios);

        jtxtCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtCodigoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtxtCorreo))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jbntCancelar)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jbtbAceptar))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel9)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel4)
                                                .addComponent(jLabel7)
                                                .addComponent(jLabel8)
                                                .addComponent(jLabel3)
                                                .addComponent(jLabel6)
                                                .addComponent(jLabel2))
                                            .addComponent(jLabel5)))
                                    .addGap(28, 28, 28))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel1)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(1, 1, 1)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jtxtDireccion, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jcmbDepartamento, javax.swing.GroupLayout.Alignment.TRAILING, 0, 268, Short.MAX_VALUE)
                                        .addComponent(jcmbProvincia, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jcmDistrito, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jtxtTelefono, javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jtxtContacto)))
                                .addComponent(jtxtRazon, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jtxtRuc)
                                .addComponent(jtxtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jLabel11)
                    .addComponent(jScrollPane1))
                .addContainerGap(16, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtxtRuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtxtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jcmbDepartamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jcmbProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jcmDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtxtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jtxtContacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jtxtCorreo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtbAceptar)
                    .addComponent(jbntCancelar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbntCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbntCancelarActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_jbntCancelarActionPerformed

    private void jtxtCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtCodigoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtCodigoActionPerformed

    private void jbtbAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtbAceptarActionPerformed
        // TODO add your handling code here:
        Proveedor prov = new Proveedor();
       
        prov.setCodigo(jtxtCodigo.getText());
        prov.setRazon_social(jtxtRazon.getText());
        prov.setRuc(jtxtRuc.getText());
        prov.setDireccion(jtxtDireccion.getText());
        prov.setDepartamento(jcmbDepartamento.getName());
        prov.setProvincia(jcmbProvincia.getName());
        prov.setDistrito(jcmDistrito.getName());
        prov.setTelefono(jtxtTelefono.getText());
        prov.setContacto(jtxtContacto.getText());
        prov.setCorreo(jtxtCorreo.getText());
        prov.setComentarios(jtxaComentarios.getText());
        
        ProveedorDAO proveedorDAO = factory.getProveedor();
        proveedorDAO.insertarProveedor(prov);
        
        jtxtCodigo.setText("");
        jtxtRazon.setText("");
        jtxtRuc.setText("");
        jtxtDireccion.setText("");
        jtxtTelefono.setText("");
        jtxtContacto.setText("");
        jtxtCorreo.setText("");
        jtxaComentarios.setText("");
        
    }//GEN-LAST:event_jbtbAceptarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmCreacionProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmCreacionProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmCreacionProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmCreacionProveedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmCreacionProveedor().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbntCancelar;
    private javax.swing.JButton jbtbAceptar;
    private javax.swing.JComboBox jcmDistrito;
    private javax.swing.JComboBox jcmbDepartamento;
    private javax.swing.JComboBox jcmbProvincia;
    private javax.swing.JTextArea jtxaComentarios;
    private javax.swing.JTextField jtxtCodigo;
    private javax.swing.JTextField jtxtContacto;
    private javax.swing.JTextField jtxtCorreo;
    private javax.swing.JTextField jtxtDireccion;
    private javax.swing.JTextField jtxtRazon;
    private javax.swing.JTextField jtxtRuc;
    private javax.swing.JTextField jtxtTelefono;
    // End of variables declaration//GEN-END:variables
}
